package com.javabase.y2021.m12.day1224;

import java.io.IOException;
import java.io.PrintStream;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @descriptions: Server
 * @author: Tom
 * @date: 2021/12/24 下午 05:20
 * @version: 1.0
 */
public class Server {
    public static void main(String[] args) throws IOException {
        ServerSocket ss = new ServerSocket(30000);
        while(true){
            // 每當接收客戶端Socket的請求時,服務端也對應產生一個Socket
            Socket s = ss.accept();
            PrintStream ps = new PrintStream(s.getOutputStream());
            // 進行普通IO操作
            ps.println("您好,您收到了服務器的新年祝福!");
            ps.close();
            s.close();
        }
    }
}
